package com.company.demo2;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class TestDemo {
    public static void main(String[] args) throws NoSuchFieldException, NoSuchMethodException {

        Class c=Student.class;

        MyAnnotation m1=(MyAnnotation)c.getAnnotation(MyAnnotation.class);
        System.out.println(m1.value());

        Field f=c.getDeclaredField("name");
        MyAnnotation m2=(MyAnnotation)f.getAnnotation(MyAnnotation.class);
        System.out.println(m2.value());

        Method m=c.getDeclaredMethod("study",new Class[]{});
        MyAnnotation m3=(MyAnnotation)m.getAnnotation(MyAnnotation.class);
        System.out.println(m3.value());
    }
}
